//
//  GCAlertViewTemplate.m
//  GCAlertViewDemo
//
//  Created by 贺晓阳 on 2020/11/14.
//

#import "GCAlertViewTemplate.h"
#import "GCAlertViewFeathers.h"
#import "DAlertView.h"


@implementation GCAlertViewTemplate

- (void)buildGCAlertView:(GCAlertViewFeathers *)feathers {
    
    DAlertView *alert = [DAlertView alertWithTitle:feathers.title message:feathers.contentText];
    alert.tag = feathers.tag;
    alert.titleColor = [UIColor blackColor];
    alert.isTapDismiss = NO;
    alert.messageFont = [UIFont systemFontOfSize:16];
    alert.messageColor = [UIColor blackColor];
    self.alertView = alert;
}

- (void)addAction:(NSString *)buttonTitle color:(UIColor *)color font:(UIFont *)font click:(void (^)(void))clickBlock{
    
    DAlertAction *action = [DAlertAction actionWithTitle:buttonTitle style:DAlertActionStyleDefault handler:^(DAlertAction * _Nonnull action) {
        // 点击按钮，需要触发回调
        if (clickBlock) {
            clickBlock();
        }
    }];
    action.titleColor = color;
    action.titleFont = font;
    [(DAlertView *)self.alertView addAction:action];
}

- (void)show {
    [(DAlertView *)self.alertView showWithAnimation];
}

- (void)dismiss {
    [(DAlertView *)self.alertView dismiss];
}

@end
